<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="../../util/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>添加字典</title>
</head>
<body>
<div id="editMdDataForm" style="width:630px;">
        <div class="form-Container">
            <form action="${pageContext.request.contextPath}/mdData/editMdData.do"  id="dataForm" class="grayForm" method="post">
                <input type="hidden" name="id" value="${param.id }"/>
                <input type="hidden" name="uuid" id="uuid" value=""/>
                <table>
                    <tr>
                        <td ><label for="duizhaoTitle">对照:</label></td>
                        <td colspan="3" style="line-height:20px;">
                            <span id="duizhaoTitle"></span>
                        </td>
                    </tr>
                    <tr>
                        <td ><label for="titleGanCi">标题敏感词:</label></td>
                        <td style="line-height:20px;"><input type="text" id="titleGanCi" required name="titleGanCi"  /></td>
                        <td ><label for="pingpaiGanCi">品牌敏感词:</label></td>
                        <td style="line-height:20px;"><input type="text" id="pingpaiGanCi" required name="pingpaiGanCi"  /></td>
                    </tr>
                    <tr>
                        <td ><label for="parentName">词条修改:</label></td>
                        <td colspan="3" style="line-height:20px;">
                            <input type="text" id="dataTitle" required name="dataTitle"   style="width:420px" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4" style="text-align: center;">
                            <input type="button" value="提交数据" name="submitData"  />
                        </td>
                    </tr>
                </table>
                <div id="confirmMsg"></div>
            </form>
        </div>
</div>
  <script type="text/javascript">
        $(document).ready(function () {
        	
        	var id = new Number($("#editDictionaryForm  input[name='id']").val());
        	var rules = {}
        	var messages = {}
        	messages = {
        	     dataTitle:"请输入词条"
            };
        	
        	var validateForm = $("#editDictionaryForm #dataForm").validate({
                debug:true,
                rules:rules,
                messages:messages
            });
        	
            //提交数据到服务器
            $("#editMdDataForm input[name='submitData']").click(function () {
            	//提交表单进行验证
            	//$("#editMdDataForm #dataForm").submit();
                //var validateFlag = validateForm.form();
                var validateFlag  = true;
                var actionUrl = $("#editMdDataForm #dataForm").attr("action");
            	var formData  = $("#editMdDataForm #dataForm").form2Json();
            	if(validateFlag){
            		$("#editMdDataForm #dataForm").form('submit',{
            			//当提交时
            			onSubmit:function(param){
            			},
            			success:function(data){
            				// change the JSON string to javascript object 
            				var data = eval('(' + data + ')');
            				if(data.code=="00"){
            					$.messager.alert('操作提示',"编辑操作成功，重新检测该词条在后台运行!",'error');
              					$("#editDataFormArea").window("close");
            					tableObject.datagrid('reload');
              			    }else{
              				   $.messager.alert('操作提示',data.message,'error');
              			    }
            			}
            		});
            	}
            });
            
            var id = $("#editMdDataForm input[name='id']").val();
        	if(id>0){
        		//加载表单数据
            	loadFormData(id+"");
        	}
        });
        
        //通过表单加载数据
        function loadFormData(id){
        	$.post(getBasePath()+"/mdData/js/getMdDataDetail.do",{id:id},function(jsonData){
        		$("#editMdDataForm #dataForm").form("load",jsonData.data);
  		    },"json");
        }
    </script>
</body>
</html>